import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: "/login",
      meta: {
        hidden: true,
        title: "重定向"
      },
    },
    {
      path: '/home',
      name: 'Home',
      meta: {
        title: "控制台",
      },
      component: () => import("@/Layout/Index.vue"),
      children: [
        {
          path: "/console",
          name: "Console",
          meta: {
            title: "控制台首页",
            icon: 'home'
          },
          component: () => import("@/views/console/Index.vue"),
        }
      ]
    },
    {
      path: '/news',
      name: 'News',
      meta: {
        title: "信息管理",
        icon: 'information'
      },
      component: () => import("@/Layout/Index.vue"),
      children: [
        {
          path: "/newsIndex",
          name: "NewsIndex",
          meta: {
            title: "信息列表",
            icon: 'user'

          },
          component: () => import("@/views/info/Index.vue"),
        },
        {
          path: "/newsCategory",
          name: "NewsCategory",
          meta: {
            title: "信息分类",
            icon: 'home'
          },
          component: () => import("@/views/info/Category.vue"),
        },
        {
          path: "/newsDetailed",
          name: "NewsDetailed",
          meta: {
            hidden: true,
            title: "信息详情"
          },
          component: () => import("@/views/info/Detailed.vue"),
        },
      ]
    },
    {
      path: '/user',
      name: 'User',
      meta: {
        title: "用户管理",
      },
      component: () => import("@/Layout/Index.vue"),
      children: [
        {
          path: "/userIndex",
          name: "UserIndex",
          meta: {
            title: "用户列表",
            icon: 'user'
          },
          component: () => import("@/views/user/Index.vue"),
        },
      ]
    },
    {
      path: '/login',
      name: 'Login',
      meta: {
        hidden: true,
        title: "登录页"
      },
      component: () => import("@/views/account/Login.vue")
    },
    {
      path: '/:pathMatch(.*)',
      name: '404',
      component: () => import('../views/404.vue')
    }
  ]
})

export default router;
